package com.jsh.erp.controller;

import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.service.UserService;
import com.jsh.erp.utils.BaseResponseInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class LoginController {

    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public BaseResponseInfo login(@RequestBody User user) throws Exception {
        log.debug("user:{}", user);
        return userService.login(user);
    }

    @GetMapping("/logout")
    public BaseResponseInfo logout() {
        log.debug("logout...");
        return userService.logout();
    }





}
